// component/coupon/index.js
const app = getApp()
Component({
    /**
     * 组件的属性列表
     */
    properties: {

    },

    /**
     * 组件的初始数据
     */
    data: {
        show: false,
       couponsum: '',
    },

    /**
     * 组件的方法列表
     */
    methods: {
        hide_notice() {
            this.setData({        
                show: false,
            })
            //couponshowstore_id
            var store_id= wx.getStorageSync('couponshowstore_id')
            console.log(store_id)
            wx.navigateTo({
                url:'/pages/present/index?room_id='+store_id,
            });
        }
    },
    attached() {
        let that = this;
        var store_id= wx.getStorageSync('couponshowstore_id')
        console.log('店铺'+store_id)
        app.http.post(app.api.coupontc, {
            store_id: store_id
          }, (res) => {
            wx.setStorageSync('couponsum', 0)
            if (res.data ==0) {
              wx.setStorageSync('couponshow', false)
            } else {
              wx.setStorageSync('couponshow', true)
              this.setData({        
                couponsum: res.data,
            })
            }
          })



        if(wx.getStorageSync('couponshow')){
            var couponsum= wx.getStorageSync('couponsum')
            that.setData({        
                show: wx.getStorageSync('couponshow'),
                couponsum:couponsum
            })

          console.log('优惠卷'+that.data.couponsum)
        }
        
    }
   
})